package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.entity.DamageListGoods;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.OverflowListGoodsService;
import com.atguigu.jxc.vo.OverflowSaveGoodsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author ONIE
 * @create 2021/11/26 10:25 上午
 */
@RestController
@RequestMapping("overflowListGoods")
public class OverflowListGoodsController {

	@Autowired
	private OverflowListGoodsService overflowListGoodsService;


	/**
	 *
	 * @param overflowNumber
	 * @param overflowSaveGoodsVo
	 * @return
	 */
	@PostMapping("save")
	public ServiceVO saveOverflow(@RequestParam String overflowNumber, OverflowSaveGoodsVo overflowSaveGoodsVo){
		overflowListGoodsService.saveOverflowSaveGoods(overflowNumber,overflowSaveGoodsVo);
		return new ServiceVO(100,"请求成功",null);
	}

	/**
	 * 报溢单查询
	 * @param sTime
	 * @param eTime
	 * @return
	 */
	@PostMapping("list")
	public Map<String, Object> listOverflow(@RequestParam String sTime,@RequestParam String eTime){
		List<OverflowList> overflowList= overflowListGoodsService.listOverflow(sTime,eTime);
		Map<String, Object> params = new HashMap<>();
		params.put("rows",overflowList);
		return params;
	}

	/**
	 * 报溢单商品信息
	 * @param overflowListId
	 * @return
	 */
	@PostMapping("goodsList")
	public Map<String, Object> goodsList(@RequestParam Integer overflowListId){
		List<OverflowListGoods> overflowListGoodsList= overflowListGoodsService.goodsList(overflowListId);
		Map<String, Object> params = new HashMap<>();
		params.put("rows",overflowListGoodsList);
		return params;
	}

}
